/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tpdisenio2009.model.beans;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author DeuterioX
 */
@Entity
@Table(name = "tournament_date")
@NamedQueries({
    @NamedQuery(name = "TournamentDate.findAll", query = "SELECT t FROM TournamentDate t")})
public class TournamentDate implements Serializable {
    private static final long serialVersionUID = 1L;

    public static final String CLOSED_DATE = "Cerrada";
    public static final String OPEN_DATE = "Abierta";

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = true)
    @Column(name = "initial_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date initialDate;
    @Basic(optional = true)
    @Column(name="ban_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date banDate;
    @Basic(optional = false)
    @Column(name = "state")
    private String state;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tournamentDate")
    private Collection<SoccerMatch> soccerMatchCollection;

    public TournamentDate() {
    }

    public TournamentDate(Integer id) {
        this.id = id;
    }

    public TournamentDate(Integer id, Date initialDate, Date banDate, String state) {
        this.id = id;
        this.initialDate = initialDate;
        this.banDate = banDate;
        this.state = state;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getInitialDate() {
        return initialDate;
    }

    public void setInitialDate(Date initialDate) {
        this.initialDate = initialDate;
    }

    public Date getBanDate() {
        return banDate;
    }

    public void setBanDate(Date banDate) {
        this.banDate = banDate;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Collection<SoccerMatch> getSoccerMatchCollection() {
        return soccerMatchCollection;
    }

    public void setSoccerMatchCollection(Collection<SoccerMatch> soccerMatchCollection) {
        this.soccerMatchCollection = soccerMatchCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TournamentDate)) {
            return false;
        }
        TournamentDate other = (TournamentDate) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return id.toString();
    }

}
